home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 701-725 / 709 / planets / sidereal_time.c < prev   
C/C++ Source or Header  |  1995-03-18  |  3KB  |  75 lines

  1. /*******************************************************************************
  2. ** SIDEREAL_TIME.C: Compute the mean sidereal time.                           **
  3. *******************************************************************************/
  4.  
  5. #include <math.h>
  6.  
  7. /*******************************************************************************
  8. ** For easy formulation we invent some abbreviations.                         **
  9. ** They include RAD = PI/180, i.e., radians per circle, and some equinoctiae, **
  10. ** like JD1900 for the year 1900 and JD2000 for the year 2000, both in        **
  11. ** Julian date for the 1st of January, 0h.                                    **
  12. *******************************************************************************/
  13. #define RAD 0.01745329251994329651
  14.  
  15. #define JD1900 2415020.
  16. #define JD2000 2451545.
  17.  
  18. #define JJ100 36525.
  19.  
  20. double sidereal_time(jd)
  21. double jd;
  22.    {
  23.    double st,t,x;
  24.    double range(),poly();
  25.  
  26. /*******************************************************************************
  27. ** Find time at UTC 0 hours.                                                  **
  28. *******************************************************************************/
  29.    x = 0.5 + floor(jd - 0.5);
  30.  
  31. /*******************************************************************************
  32. ** They are a few fractions of a second off, I don't know which one is right. **
  33. ** But I do: The NAVY uses the equinoctium to the year 2000, Meeus that to    **
  34. ** the year 1900. Hence the difference, due to precision.                     **
  35. *******************************************************************************/
  36. #ifdef YOU_BELIEVE_THE_NAVY
  37.  
  38. /*******************************************************************************
  39. ** Compute mean sidereal time according to NAVY Almanac.                      **
  40. *******************************************************************************/
  41.    t  = (x - JD2000) / JJ100;
  42.    st = poly(0.2790572733,100.002139,0.0000010776,0.,t);
  43.    st = 24. * (st - floor(st));
  44.  
  45. /*******************************************************************************
  46. ** Add in UTC with fudge factor.                                              **
  47. *******************************************************************************/
  48.    st += (jd - x) * 24. * 1.002737909;
  49.  
  50. /*******************************************************************************
  51. ** Compute correction for equation of equinoxes.                              **
  52. *******************************************************************************/
  53.    st -= 0.00029*sin(range(poly(125.04452,-1934.13626,-0.002071,0.,t))*RAD)/RAD;
  54.  
  55. #else
  56. /*******************************************************************************
  57. ** Compute GAST according to Meeus Book.                                      **
  58. *******************************************************************************/
  59.    t  = (x - JD1900) / JJ100;
  60.    st = poly(0.276919398,100.0021359,0.000001075,0.,t);
  61.    st = 24. * (st - floor(st));
  62.    
  63. /*******************************************************************************
  64. ** Add in UTC with fudge factor.                                              **
  65. *******************************************************************************/
  66.    st += (jd - x) * 24. * 1.002737908;
  67.  
  68. #endif
  69.  
  70.    if (st > 24.)
  71.       st -= 24.;
  72.  
  73.    return(st);
  74.    }
  75.